const mongoose = require("mongoose");
mongoose
  .connect("mongodb://localhost:27017/group-project")
  .then(() => {
    console.log("数据库连接成功");
  })
  .catch(() => {
    console.log("数据库连接失败");
  });
  // 引入userSchema
const userSchema = new mongoose.Schema({
  username: { type: String, required: true },
  password: { type: String, required: true },
});
// 创建超市告警信息
const supermarketSchema = new mongoose.Schema({
  id: { type: Number, required: true },
  store: { type: String, required: true },
  category: { type: String, required: true },
  name: { type: String, required: true },
  stock: { type: Number, required: true },
  alarm: { type: String, required: true },
});
// 引入userModel
const userModel = mongoose.model("user", userSchema, "user");
// 引入supermarketModel
const supermarketModel = mongoose.model("supermarket", supermarketSchema, "supermarket");
// 导出userModel
module.exports = {
  userModel,
  supermarketModel,
};
